<?php
abstract class Environment
{
	private $_debugMode = false;
	private $_yiiPath = './../../yii/yii.php';
	
	public function setDebugMode($mode)
	{
		$this->_debugMode = $mode;	
	}
	
	public function getDebugMode()
	{
		return $this->_debugMode;
	}
	
	public function setYiiPath($yiiPath)
	{
		$this->_yiiPath = $yiiPath;	
	}
	
	public function getYiiPath()
	{
		return $this->_yiiPath;	
	}
	
	 public function getConfiguration()
	 {
	 	$servers = Servers::getServers($_SERVER['HTTP_HOST']);
	 	$this->setYiiPath($servers['yiiPath']);
	 	return array(
						'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
						'name'=>$servers['name'],
						'sourceLanguage' => 'en',
						'language' => 'es',
						'theme'=>'cup',
						// preloading 'log' component
						'preload'=>array('log'),
						// autoloading model and component classes
						'import'=>$this->getImport(),
						'modules'=>$this->getModules(),
						// application components
						'components'=>$this->getComponents(),
						'params'=>array(
										// this is used in contact page
										'adminEmail'=>'webmaster@cup.edu.ar'
						),
						
		);
	 }
	
	 
	 
	
	public function getImport()
	{
		return array(
						'application.models.*',
						'application.components.*',
						//rigths
						'application.modules.rights.*',
						'application.modules.rights.components.*',
						'application.modules.rights.services.*',
		
						'application.modules.persona.models.*',
						
						'application.modules.persona.services.*',
						'application.modules.carrera.services.*',
						'application.modules.contable.services.*',
						'application.modules.infraestructura.services.InfraestructuraMenu',
		

						'application.modules.direccion.services.*',
						'application.modules.marketing.models.*',
						'application.modules.auditTrail.models.AuditTrail',		
					);
	}
	
	public function getModules()
	{
		return array(
						'nucleo',
						'direccion',
						'persona',
						'comunicacion',
						'contable',
						'carrera',
						'marketing',
						'infraestructura',
		
						'rights'=>array( 
											'userClass'=>'Usuario',
											'userIdColumn'=>'usuario_id', 
											'userNameColumn'=>'usuario_nombre',
											'install'=>false, // Enables the installer. 
											'debug'=>true,
						),
						// 	uncomment the following to enable the Gii tool
						'gii'=>array(
										'class'=>'system.gii.GiiModule',
										'password'=>'admin',
							 			'ipFilters'=>array('127.0.0.1','::1'),
						),
						'auditTrail'=>array(),
						
		
		);
	}
	
	//COMPONENTS 
	public function getComponentAuthManager()
	{
		return array(
			            'class'=>'RDbAuthManager',
			            'connectionID'=>'db',
						'itemTable'=>'tbl_authitem', // Tabla que contiene los elementos de autorizacion
			        	'itemChildTable'=>'tbl_authitemchild', // Tabla que contiene los elementos padre-hijo
			        	'assignmentTable'=>'tbl_authassignment', // Tabla que contiene la signacion usuario-autorizacion
						'defaultRoles'=>array('Guest'),
		);
	}
	
	public function getComponentUser()
	{
		return array(
										// enable cookie-based authentication
										'allowAutoLogin'=>true,
										'class' => 'WebUser',
						);
	}
	
	public function getComponentURLManager()
	{
		return array(
						'urlFormat'=>'path',
						'showScriptName'=>false,
						'rules'=>array(
										'<controller:\w+>/<id:\d+>'=>'<controller>/view',
										'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
										'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
						),
		);
	}
	//por defecto la base de datos de desarrollo
	public function getComponentDB()
	{
		return array(
						'connectionString' => 'mysql:host=localhost;dbname=southfq5_cup_autogestion',
						'emulatePrepare' => true,
						'username' => 'southfq5_sscupau',
						'password' => 'Cambiar1977',
						'charset' => 'utf8',
					 	'enableProfiling'=>true,
					 	'enableParamLogging'=>true,
		);
	}
	
	public function getComponentErrorHandle()
	{
		return array(
						'errorAction'=>'site/error',
		);
	}
	
	public function getComponents()
	{
		return array(
						'authManager'=>$this->getComponentAuthManager(),
						'user'=>$this->getComponentUser(),
						// uncomment the following to enable URLs in path-format
						'urlManager'=>$this->getComponentURLManager(),
						'db'=>$this->getComponentDB(),
						'errorHandler'=>$this->getComponentErrorHandle(),
						'log'=>$this->getComponentLog(),
						'CURL' =>array(
										'class' => 'application.extensions.curl.Curl',
     									//you can setup timeout,http_login,proxy,proxylogin,cookie, and setOPTIONS
 						)
				);
	}
	 
}